"use script";

const sequelize = require("sequelize");

module.exports = (app) => {
  const { INTEGER } = sequelize;
  const role_menu = app.model.define(
    "role_menu",
    {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
      },
      roleId: {
        field: "role_id",
        type: INTEGER,
        allowNull: false,
        references: {
          model: "role",
          key: "id",
        },
      },
      menuId: {
        field: "menu_id",
        type: INTEGER,
        allowNull: false,
        references: {
          model: "menu",
          key: "id",
        },
      },
    },
    {
      tableName: "role_menu",
      timestamps: false,
    }
  );

  return role_menu;
};
